<template>
  <div>
      <h1>房间管理</h1>
      姓名：<input type="text" v-model="param.name"/><br>
      <img src="" id="pic" width="300" height="300"><br> 
      头像：<input type="file" @change="getFile($event)"/>
      <input type="button" value="提交" @click="formSubmit()"/>
  </div>
</template>

<script>
export default {
     data(){
       return {
          param:{}
       }
     },
     methods:{
       getFile(event){
         //得到文件表单的dom对象
           this.param.face = event.target.files[0];
           var reader = new FileReader();//定义文件读取流对象
            reader.readAsDataURL(this.param.face);
            reader.onload = function (ev) {
                document.getElementById("pic").src = ev.target.result;
            }
       },
       async formSubmit(){
            var info = await this.ajax.uploadSubmit("/project/upload/add",this.param);
            alert(info);
       }
     }
}
</script>

<style>

</style>